CURRENT_PATH=$(pwd)
PROJECT_PATH=$(dirname "${CURRENT_PATH}")
if [ ! -d "${PROJECT_PATH}/smart-editor-mount" ]; then 
    cd $PROJECT_PATH 
    mkdir -p $PROJECT_PATH/smart-editor-mount/logs
    mkdir -p $PROJECT_PATH/smart-editor-mount/service_datas 
    cp -rf $CURRENT_PATH/etc $PROJECT_PATH/smart-editor-mount
fi  

DOCKER_CONTAINER=$(docker container ls -a | grep smarteditor | awk '{print $1}')
echo $DOCKER_CONTAINER

if [ ${#DOCKER_CONTAINER} -gt 1 ]; then 
    docker restart  $DOCKER_CONTAINER
else 
    docker run -p 7080:7080 -p 50051:50051 \
    --env GOROOT=/data/go230 \
    --env GOPATH=/data/gopath230 \
    --env PATH=$GOPATH/bin:$GOROOT/bin:$PATH \
    --env GOBIN=/data/go230/bin \
    --name smarteditor \
    -v $PROJECT_PATH/smart-editor-mount/etc:/smarteditor/etc \
    -v $PROJECT_PATH/smart-editor-mount/service_datas:/data/wide  \
    -v $PROJECT_PATH/smart-editor-mount/logs:/smarteditor/logs \
    -d smarteditor:v1.0.0
fi 